/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hibernate.dao.impl;

import hibernate.GenericDAOHibernate;
import hibernate.dao.PedidoClienteDAO;
import hibernate.entidades.DetallePedCli;
import hibernate.entidades.PedidoCliente;
import hibernate.exception.BussinessException;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

/**
 *
 * @author ariel
 */
public class PedidoClienteDAOImpl extends GenericDAOHibernate<PedidoCliente, Integer> implements PedidoClienteDAO {

    @Override
    public double getTotalPedido(int id) throws BussinessException {
        double total = 0;
        PedidoCliente get = this.get(id);
        List<DetallePedCli> detalles = get.getDetallePedCliList();
        Iterator<DetallePedCli> iterator = detalles.iterator();
        while (iterator.hasNext()) {
            DetallePedCli next = iterator.next();
            total = total + (next.getCantidad() * next.getCodStock().getPrecio());
        }
        return total;
    }
}
